﻿//-----------------------------------------------------------------------
// <copyright file="MemberExtensions.cs" company="COMPANY">
//     Copyright (c) COPYRIGHT. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace CodeQualityExtension.Framework
{
    using Microsoft.FxCop.Sdk;
    
    /// <summary>
    /// Extensions for <see cref="Microsoft.FxCop.Sdk.Member"/>
    /// </summary>
    public static class MemberExtensions
    {
        /// <summary>
        /// Checks whether specified member is marked with attribute
        /// </summary>
        /// <param name="member">Member to analyze (e.g. class or method)</param>
        /// <param name="attributeName">Full name of attribute class (including namespace)</param>
        /// <returns>True if member is marked with attribute</returns>
        public static bool HasAttribute(this Member member, string attributeName)
        {
            AttributeNode attributeNode = member.Attributes.FindByName(attributeName);

            return attributeNode != null;
        }
    }
}
